package com.test;

/**
 *  有十个车位，有15台车（15个线程）要进去，用多线程模拟进车出车的情况
 */
public class demo3 extends Thread{
    Stop stop;
    car car;



    @Override
    public void run() {
        stop.comeCar(car);

    }

    public static void main(String[] args) {
        Stop stop = new Stop();

    }




}
class car {


}
class Stop{
    public boolean isfull(){
        if (c>=15){

        }
        return false;
    }
    car[] cars=new car[15];
    int c=0;

    public synchronized void comeCar(car carNum){
        while (c>=cars.length){
            try {
                this.wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
        cars[c]= carNum;
        c++;

    }
    public synchronized void goOut(){
        while (c>=1){
            c--;
            car car2=cars[c];
            cars[c]=null;



        }

    }

}
